package com.javastudy.liuhouse.bank_demo;

public class BankAccount
{
    private String accountNumber;
    private String accountHolderName;
    private double balance;

    //构造函数
    public BankAccount(String accountNumber, String accountHolderName, double balance) {
        this.accountNumber = accountNumber;
        this.accountHolderName = accountHolderName;
        this.balance = balance;
    }


    //存款
    public void deposit(double amount){
        if(amount > 0){
            balance += amount;
            System.out.println("存款成功,当前余额:" + balance);
        }else{
            System.out.println("存款金额必须大于0");
        }
    }

    //取款
    public void withdraw(double amount){
        if(amount > 0 && amount <= balance){
            balance -= amount;
            System.out.println("取款成功!当前余额:" + balance);
        }else{
            System.out.println("取款失败!余额不足或者取款金额无效");
        }
    }


    //查询余额
    public void checkBalance(){
        System.out.println("账户余额:" + balance);
    }

    //获取账户信息
    public void getAccountInfo(){
        System.out.println("账户号码:" + accountNumber);
        System.out.println("账户持有人:" + accountHolderName);
        System.out.println("账户余额:" + balance);
    }

}
